package com.topdt.jbpm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thx.common.service.BaseManager;
import com.thx.common.web.Page;
import com.topdt.jbpm.dao.FlowDao;
import com.topdt.jbpm.dao.FlowDetailDao;
import com.topdt.jbpm.model.AppType;
import com.topdt.jbpm.model.Flow;
import com.topdt.jbpm.model.FlowDetail;

/**
 * 建立日期 : 2013-6-20 <br>
 * 作者 : 武海峰<br>
 * 模块 : <br>
 * 描述 : <br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 */
@Service
@Transactional(readOnly = true)
public class FlowService extends BaseManager<Flow>{

	@Autowired
	private FlowDao flowDao;
	@Autowired
	private FlowDetailDao flowDetailDao;
    public List<Flow> getAllFillSelect(){
    	return flowDao.getAllFillSelect();
    }
	public List<Flow> getAllByFlowName(String flowName) {
		return flowDao.getAllByFlowName(flowName);
	}
	
	public List<Flow> findByName(String flowName) {
		return flowDao.findByName(flowName);
	}
	
	/**
	 * 判断是否存在 流程 建立日期 : Sep 23, 2013 5:23:14 PM<br>
	 * 作者: 孙耀飞<br>
	 * 模块: <br>
	 * 描述: 保存流程定义的时候<br>
	 * 1 <br>
	 * 2 <br>
	 */
	public String checkFlowName(String detailId, String flowName) {
		/*FlowDetail flowDetail = flowDetailDao.findById(detailId);
		Flow flowByName = this.getFlowByFlowName(flowName);
		if (flowDetail != null) {
			Flow flow = this.flowDao.getById(flowDetail.getFlowId());
			if (flow != null) {
				if (flow.getFlowName().equals(flowName)) {
					return "success";
				} else {
					if (flowByName != null) {
						return "false";
					} else {
						return "success";
					}
				}
			} else {
				if (flowByName != null) {
					return "false";
				} else {
					return "success";
				}
			}
		} else {
			if (flowByName != null) {
				return "false";
			} else {
				return "success";
			}
		}*/
		return "success";
	}
	
}
